class Stack {
    constructor() {
        this.data = [];
        this.top = -1;
    }

    insert(item) {
        this.data[++this.top] = item;
    }

    pop() {
        if (this.top === -1) {
            return null;
        }
        return this.data.splice(this.top--, 1)[0]
    }

    toString() {
        return this.data.toString();
    }

    length() {
        return data.length;
    }
}

exports.Stack = Stack;